﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cofe.Core
{
    /// <summary>
    /// Status of an EntryList, or a COFEWork.
    /// </summary>
    public enum StatusType
    {
        /// <summary>
        /// Unspecified.
        /// </summary>
        Unknown,
        /// <summary>
        /// Entry list / Work is just created.
        /// </summary>
        Initalized,
        /// <summary>
        /// Entry List is listing / Work is working.
        /// </summary>
        Working,
        /// <summary>
        /// Work is Paused.
        /// </summary>
        Paused,
        /// <summary>
        /// Error triggered when listing / working.
        /// </summary>
        Error,
        /// <summary>
        /// Listing / Work is completed.
        /// </summary>
        Completed
    }

    /// <summary>
    /// Extends StatusType.
    /// </summary>
    public static class StatusTypeExtension
    {
        /// <summary>
        /// Parse StatusType string to StatusType.
        /// </summary>
        /// <param name="entryString"></param>
        /// <returns></returns>
        public static StatusType Parse(string statusString)
        {
            try
            {
                StatusType stType = (StatusType)Enum.Parse(typeof(StatusType), statusString, true);
                return stType;
            }
            catch
            {
                return StatusType.Unknown;
            }
        }
    }
}
